/////////////////////////////////////////////////////////////////////////
//
// Amuse Engine SDK - core/system/io/readers
// Copyright (c) 2014.  All Rights Reserved
//
// File:		AEWin32BufferedStreamReader.h
// Author:		Gianluca Belardelli
// Date:		11/10/2013
//
/////////////////////////////////////////////////////////////////////////
#include <AECore.h>
#include <core\system\io\readers\AEBufferedStreamReader.h>

AEBufferedStreamReader::AEBufferedStreamReader(  AEStreamReader *lpReader, AEUINT32 uiBufferSize )
{
	m_lpReader = lpReader;
}

AEBufferedStreamReader::~AEBufferedStreamReader( void )
{
	delete m_lpReader;
}

int AEBufferedStreamReader::Read( void *lpBuf, AEINT32 nBytes )
{
	return m_lpReader->Read( lpBuf, nBytes );
}

int AEBufferedStreamReader::Skip( AEINT32 nBytes )
{
	return m_lpReader->Skip( nBytes );
}

int AEBufferedStreamReader::Peek( void *lpBuf, AEINT32 nBytes )
{
	return m_lpReader->Peek( lpBuf, nBytes );
}

AERESULT AEBufferedStreamReader::GetLastError( void ) const
{
	return m_lpReader->GetLastError();
}

AERESULT AEBufferedStreamReader::Seek( AEINT32 nOffset, AESeekOptions soOpt )
{
	if( m_lpReader->IsSeekTellSupported() )
		return m_lpReader->IsSeekTellSupported()->Seek( nOffset, soOpt );

	return 0;
}

AEINT32 AEBufferedStreamReader::Tell( void ) const
{
	if( m_lpReader->IsSeekTellSupported() )
		return m_lpReader->IsSeekTellSupported()->Tell();

	return -1;
}
